package com.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

/**
 * @classDescription:
 * @author:xiayingjie
 * @createTime:16/7/15
 */
@Configuration
@EnableWebMvc
@EnableAspectJAutoProxy
@ComponentScan({"com.**.aop","com.**.controller"})
public class WebConfig extends WebMvcConfigurerAdapter{
    //视图解析器 未配置默认使用BeanNameViewResolver
    @Bean
    public ViewResolver viewResolver(){
        InternalResourceViewResolver  irvr=new InternalResourceViewResolver();
        irvr.setPrefix("/WEB-INF/views/");
        irvr.setSuffix(".jsp");
        irvr.setExposeContextBeansAsAttributes(true);
        return null;
    }
    //配置静态资源处理器，如果是静态资源，则自动跳过
    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        //将静态资源调用转到servlet默认容器处理，dispatcherServlet不处理
        configurer.enable();
    }








}
